<?php
class CLog
{
	private $_file;

	public function init()
	{
		$this->_file = fopen(APP_PATH.'runtime/app.log', 'a');
	}

	public function write($message)
	{
		if ($this->_file)
		{
			$time = date('Y-m-d H:i:s');
			fputs($this->_file, $time.': '.$message."\n===========\n");
			fflush($this->_file);
		}
	}

	public function close()
	{
		if ($this->_file)
		{
			fclose($this->_file);
			$this->_file = null;
		}
	}
}